import { OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';


export class LiveBase {

  service: any;
  constructor(service) {

    this.service = service;
  }

  busy: Subscription;

  // pages data
  vm: any = {
    page: 1,
    table: {
      livers: [],
      count: 0
    }
  };

  // 参数
  param: any = {
    page: 0,
    start: 0,
    rows: 10
  };



  ngOnDestroy() {

    if (this.busy) {
      this.busy.unsubscribe();
    }
  }

  //分页
  pageChanged(currentPage) {

    console.log(currentPage);

    this.vm.page = currentPage;

    this.param.start = (currentPage - 1) * this.param.rows;

    this.getHttp(this.param);

  }

  getHttp(param) {

    var res = {"code":0,"msg":"成功","data":{"value":[{"darenId":263817957,"name":"韩都衣舍旗舰店","logo":"//gw3.alicdn.com/tfscom/tuitui/T1.RR_XvlaXXXXXXXX","fansNum":15831113,"area":"女装/男装/内衣--女装/女士精品","uid":263817957,"sid":58501945,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=uqu2vNLCyeHG7L2iteo%3D","modifyTime":1511442816000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":264.06,"sellAmount30Days":26456,"sellMoney30Days":6986087.0,"date":null},{"darenId":479184430,"name":"MG小象欧美街拍时尚女装","logo":"//gw2.alicdn.com/tfscom/tuitui//4b/07/TB1G_zXNpXXXXX7XFXXSutbFXXX.jpg","fansNum":15228137,"area":"女装/男装/内衣--女装/女士精品","uid":479184430,"sid":64185146,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=w6u5vdChz%2FM%3D","modifyTime":1511443151000,"price7Days":171.86,"sellAmount7Days":261.0,"sellMoney7Days":44856.0,"price30Days":135.07,"sellAmount30Days":18561,"sellMoney30Days":2507115.5,"date":null},{"darenId":880734502,"name":"松鼠饲养员","logo":"//gw3.alicdn.com/tfscom/tuitui/TB2a8lEomhlpuFjSspkXXa1ApXa_!!880734502-0-beehive-scenes.jpg","fansNum":14414809,"area":"美食/生鲜/零食--零食/坚果/特产","uid":880734502,"sid":71720200,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=yP3Wu8vJyvPG7L2iteo%3D","modifyTime":1511538118000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":19.18,"sellAmount30Days":723,"sellMoney30Days":13869.9,"date":null},{"darenId":1714128138,"name":"小米官旗","logo":"//gw3.alicdn.com/tfscom/tuitui/T1EfiMFnNdXXXXXXXX","fansNum":14346150,"area":"办公/DIY/五金电子--办公设备/耗材/相关服务","uid":1714128138,"sid":104736810,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=0KHD17nZt73G7L2iteo%3D","modifyTime":1511443216000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":206.76,"sellAmount30Days":804,"sellMoney30Days":166238.0,"date":null},{"darenId":890482188,"name":"NIKE官方旗舰店","logo":null,"fansNum":11957757,"area":null,"uid":null,"sid":null,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=bmlrZbnZt73G7L2iteo%3D","modifyTime":1512227654000,"price7Days":null,"sellAmount7Days":null,"sellMoney7Days":null,"price30Days":null,"sellAmount30Days":null,"sellMoney30Days":null,"date":null},{"darenId":619123122,"name":"良品铺子旗舰店","logo":"//gw2.alicdn.com/tfscom/tuitui//b9/bd/TB1MNdIOXXXXXaIXFXXSutbFXXX.jpg","fansNum":11701075,"area":"美食/生鲜/零食--零食/坚果/特产","uid":619123122,"sid":63552270,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=wbzGt8bM19PG7L2iteo%3D","modifyTime":1511443019000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":27.46,"sellAmount30Days":85863,"sellMoney30Days":2358073.8,"date":null},{"darenId":628189716,"name":"百草味家的小味","logo":"//gw1.alicdn.com/tfscom/tuitui/TB19X93KFXXXXXsXpXXXXXXXXXX","fansNum":10599066,"area":"美食/生鲜/零食--零食/坚果/特产","uid":628189716,"sid":63612646,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=sNmy3c62xuy9orXq","modifyTime":1511443011000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":15.93,"sellAmount30Days":18181,"sellMoney30Days":289631.2,"date":null},{"darenId":1114511827,"name":"荣耀荣嬷嬷","logo":"//gw1.alicdn.com/tfscom/tuitui/TB1xkTpJFXXXXc_aXXXXXXXXXXX","fansNum":10464783,"area":"数码/手机/家电--手机","uid":1114511827,"sid":101717810,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=yNnSq7nZt73G7L2iteo%3D","modifyTime":1511443084000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":1485.31,"sellAmount30Days":933,"sellMoney30Days":1385797.0,"date":null},{"darenId":356060330,"name":"ONLY","logo":"//gw1.alicdn.com/tfscom/tuitui/T1CKpMXE8iXXXXXXXX","fansNum":9579797,"area":"女装/男装/内衣--女装/女士精品","uid":356060330,"sid":60129786,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=b25sebnZt73G7L2iteo%3D","modifyTime":1511443252000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":36.13,"sellAmount30Days":809,"sellMoney30Days":29227.0,"date":null},{"darenId":791105148,"name":"雪梨_Cherie","logo":"//gw2.alicdn.com/tfscom/tuitui/TB1cvzTMXXXXXc8XFXXXXXXXXXX","fansNum":9534432,"area":"女装/男装/内衣--女装/女士精品","uid":791105148,"sid":69714396,"wangwangLink":"//im.m.taobao.com/ww/ad_ww_dialog.htm?to_user=x6638sjLMjA5","modifyTime":1511443433000,"price7Days":0.0,"sellAmount7Days":0.0,"sellMoney7Days":0.0,"price30Days":262.17,"sellAmount30Days":38589,"sellMoney30Days":1.01168118E7,"date":null}],"count":1000}};

    setTimeout(() => {

      this.vm.table.livers = res.data.value;

      this.vm.table.count = res.data.count;

    }, 100);
  }
}
